package com.zy.dao.impl;

import com.zy.dao.AddMarksDao;
import com.zy.utils.JdbcUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class AddMarksDaoImpl implements AddMarksDao {
    @Override
    public boolean insertMark(String content, int userId) {
        String sql = "INSERT INTO tb_marks (content, user_id) VALUES (?, ?)";
        try (Connection conn = JdbcUtil.getConnection();
             PreparedStatement pstmt = conn.prepareStatement(sql)) {
            pstmt.setString(1, content);
            pstmt.setInt(2, userId);
            int affectedRows = pstmt.executeUpdate();
            return affectedRows > 0;
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }
}
